//
//  MTZVisitorViewController.swift
//  weibomtz
//
//  Created by 毛铁柱 on 16/10/19.
//  Copyright © 2016年 mtz. All rights reserved.
//

import UIKit

class MTZVisitorViewController: UITableViewController
{
    
    
    // 设置是否登陆开关
    var userLogin:Bool = false
    
    var visitorView:MTZVisitorView?
    
    override func loadView() {
        // 用户已登录
        userLogin ? super.loadView() : setupVisitorView()
    }

    private func setupVisitorView(){
        let v = MTZVisitorView()
        visitorView = v
//        v.delegate = self
        view = v
        
    
        // 设置左右的 item
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "register")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: "login")
        // 给访客视图里面的按钮添加点击事件
        v.registerButton.addTarget(self, action: "register", forControlEvents: UIControlEvents.TouchUpInside)
        v.loginButton.addTarget(self, action: "login", forControlEvents: .TouchUpInside)
    }
    
    @objc private func register(){
        print("注册")
    }
    
    @objc private func login(){
        print("登录")
    }
    
    func registerButtonClick() {
        register()
    }
    
    func loginButtonClick() {
        login()
    }
        
    }